<?php
session_start();
if (!isset($_SESSION['stuno'])) {
    header("Location:login.php?frompage=students");
}
?>
<!DOCTYPE html>
<html lang="en">

<head>
    <style type="text/css">
        .tb {
            width: 80%;
            margin: auto;
            border: 1px solid #0094ff;
            border-collapse: collapse;
            font-size: 14px;
        }

        /* 学生信息页面表格的单元格，边框为1px蓝色，高50px,内间距0 */
        .tb tr th,
        .tb tr td {
            border: 1px solid #0094ff;
            height: 50px;
            padding: 0;
        }
    </style>

    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <?php
    include  'HeaderNav.html';
    ?>

    <h1>学生信息</h1>
    <!-- <a href="login.php?frompage=students">请先登录</a> -->
        
    <?php
        require_once "conn.php";

        $db->query("SET NAMES UTF8");

        $sql="select student.*,class.classname
              from student,class
              where student.classno=class.classno";

        if ($result=$db->query($sql)) {
            echo "<table class='tb'>
                <tr>
                    <th>学号</th>
                    <th>姓名</th>
                    <th>班级</th>
                    <th>性别</th>
                    <th>爱好</th>
                    <th>手机</th>
                    <th>邮箱</th>
                    <th>照片</th>
                </tr>
            </table>";
            while($row=$result->fetch_assoc()) {
                echo "<tr>"
                ."<td>".$row['studentid']."</td>"
                ."<td>".$row['studentname']."</td>"
                ."<td>".$row['classname']."</td>"
                ."<td>".$row['sex']."</td>"
                ."<td>".$row['hobby']."</td>"
                ."<td>".$row['mobile']."</td>"
                ."<td>".$row['email']."</td>"
                ."<td>"."<img src='".$row['photo']."' width='35px'>"."</td>"
                ."</tr>";
            }
            echo "</table>";
            $result->close();
        }
        $db->close();

        include  'Footer.html';
    ?>
</body>

</html>